{include file="common/head"}
<head>
    <title>订单综合查询</title>
    <link rel="stylesheet" href="/static/flatpickr/flatpickr.min.css">
    <script src="/static/flatpickr/flatpickr.min.js"></script>
    <style>
    .form-control{width: initial;display: inline-block;}
    </style>
</head>
<body >
<div class="container-fluid">
    <form action="/index.php/order/order_query" method="post">
    <div class="row" id="query_bar" style="height: 50px;line-height: 50px;">
        <div class="col">
        <label for="user" >下单人:
            <select id="creater" name="creater" class="form-control">
                <option value="">未选择</option>
                {foreach $user as $u}
                    <option value="{$u['id']}" {if $u['id']==$creater} selected {/if}>{$u['name']}</option>
                {/foreach}
            </select>
        </label>

        <label for="table_id" >订单状态:
            <select id="status" name="status" class="form-control">
                <option value="">未选择</option>
                {foreach $status_arr as $k=>$v}
                    <option value="{$k}"  >{$v[0]}</option>
                {/foreach}
            </select>
        </label>

        <label for="table_id" >收款方式:
            <select id="payment" name="payment" class="form-control">
                <option value="">未选择</option>
                {foreach $payments as $k=>$v}
                    <option value="{$k}"  {if $k==$payment} selected {/if}>{$v}</option>
                {/foreach}
            </select>
        </label>        

        <label for="order_no" >
            <input class="form-control" type="text" value="{$sdate}" id="sdate" name="sdate" placeholder="开始日期" />
        </label>

        <label for="sdate" >
            <input class="form-control" type="text" value="{$edate}" id="edate" name="edate" placeholder="结束日期" />
        </label>   

        <label for="edate" >
            <input class="form-control" type="text" value="" id="order_no" name="order_no" placeholder="流水号" />
        </label>

        <button type="button" class="btn query" style="display: none;" >
            <span class="bi-search" ></span>
        </button>
        </div>

    </div>
    </form>

    <table class="table table-sm table-hover table-striped" style="min-width: 100%;">
        
        <thead class="table-info">
             <th>序号</th>
            <th>流水号</th>
            <th>客户名</th>
            <th>发货地/目的地</th>
            <th>货车类型</th>
            <th>接单司机</th>
            <th>距离</th>
            <th>价格</th>
            <th>平台佣金</th>
            <th>状态</th>
            <th>

            </th>
        </thead>
        <tbody>
            {foreach $list as $k=>$kv}
            <tr>
                <td>{$k+1}</td>
                <td>{$kv['order_no']}</td>
                <td>{$kv['creater']}</td>
                <td class="long_field" title="{$kv['address1']} -> {$kv['address2']}">{$kv['address1']}<br>{$kv['address2']}</td>
                <td>{$kv['truck_type_name']}</td>
                <td>{$kv['driver_id_name']}</td>
                <td>{$kv['distance']}km</td>
                <td>{$kv['price1']}</td>
                <td>{$kv['commision']}</td>
                <td>{$kv['status_name']}</td>

                <td class="text-nowrap">
<!--                     <button tyle="button" class="btn btn-sm btn-info">
                        <span class="bi-card-list" oid="{$kv['id']}"></span>
                    </button>
                    <button tyle="button" class="btn btn-sm btn-info" >
                        <span class="bi-info" oid="{$kv['id']}"></span>
                    </button>  -->

<!--                     <button tyle="button" class="btn btn-sm btn-warning " >
                        <span class="bi-trash" oid="{$kv['id']}"></span>
                    </button>  -->
                </td>
            </tr>

            {/foreach}

            <tr class="table-primary" style="font-weight: bold;">
            {if $count>0}
                <td></td>
                <td>订单总数:</td>
                <td>{$count}</td>
                <td></td>
                <td></td>
                <td>Total:</td>
                <td>${$price1}</td>
                <td>${$commision}</td>    
                <td colspan="7"></td>
            </tr>
            {else}
                <tr><td colspan="8">无任何记录，可以试试其他查询条件。</td></tr>
            {/if}
        </tbody>    
    </table>

</div>

</body>

<script type="text/javascript">
  
  $(document).ready(function(){
    setTimeout(function(){$(".query").show()},1000);

    flatpickr("#sdate", {});
    flatpickr("#edate", {});

    $(".sdate").flatpickr({
        enableTime: true,
        dateFormat: "Y-m-d H:i:s",
    });
    $(".edate").flatpickr({
        enableTime: true,
        dateFormat: "Y-m-d H:i",
    });

    $(".bi-card-list").on('click',function(){
        var oid =$(this).attr('oid');
        layer.open({
          type: 2,
          title: '订单明细',
          shadeClose: true,
          shade: false,
          maxmin: true, //开启最大化最小化按钮
          area: ['500px', '600px'],
          content: '/index.php/order/order_list/id/'+oid
        });
    })

    $(".bi-info").on('click',function(){
        var oid =$(this).attr('oid');
        layer.open({
          type: 2,
          title: '订单记录',
          shadeClose: true,
          shade: false,
          maxmin: true, //开启最大化最小化按钮
          area: ['700px', '600px'],
          content: '/index.php/order/order_log/id/'+oid
        });
    })

    $(".query").on('click',function(){
        var cid = $("#customer_id").val();
        var order_no = $("#order_no").val();
        var sdate = $("#sdate").val();
        var edate = $("#edate").val();
        $("form").submit();
    })

    $(".bi-trash").on('click',function(){
        var oid=$(this).attr('oid');
        layer.confirm('确认取消订单吗？', {
          btn: ['Yes','No'] //按钮
        }, function(){

          $.post("/index.php/order/order_cancel",{id:oid,memo:'管理员取消'},function(res){
            var res=JSON.parse();
            layer.msg(res.msg);
          });

        }, function(){
            layer.msg('取消操作!');
        });

    })
     
  })



</script>

</body>
</html>
